home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / examples / layerfuncs < prev    next >
Encoding:
Text File  |  2000-03-28  |  1021 b   |  33 lines

  1. #!/usr/app/bin/perl -w
  2.  
  3. eval 'exec /usr/app/bin/perl -w -S $0 ${1+"$@"}'
  4.     if 0; # not running under some shell
  5. # <sjburges@gimp.org>
  6. use Gimp;
  7. use Gimp::Fu;
  8. use Gimp::Util;
  9. # Gimp::set_trace(TRACE_ALL);
  10.  
  11. # These are a couple of one-liners that you might find handy.  Both should
  12. # be undoable w/o any special magick, and work with any gimp.
  13.  
  14. register "layer_to_image_size", "Layer2ImageSize", "Expands layer to image size",
  15.          "Seth Burgess", "Seth Burgess <sjburges\@gimp.org>", "1.0",
  16.          "<None>", "*", [ ], sub {
  17.    ($img, $layer) = @_;
  18.    $layer->resize($img->width, $img->height, $layer->offsets);
  19.    return();
  20. };
  21.  
  22. register "center_layer", "Center Layer", 
  23.          "Centers the current layer on the image", 
  24.          "Seth Burgess", "Seth Burgess <sjburges\@gimp.org>", 
  25.          "1.0", N_"<Image>/Layers/Center Layer", "*", [], sub {
  26.     ($img, $layer) = @_;
  27.     $layer->set_offsets(($img->width  - $layer->width )/2, 
  28.                         ($img->height - $layer->height)/2);
  29.     return();
  30. };
  31.  
  32. exit main;
  33.